

from openpyxl.styles.builtins import total
from common.public import *
from orm.model import RegistrationSheet, db
from view.baseview import BaseView


class ApplicantDetailsView(BaseView):
    def __init__(self):
        pass

    @db.atomic()
    def updateRegistration(self, params):
        """
                        修改补充信息    
        """
        print(params)
        
        p, created = RegistrationSheet.get_or_create(identity_card = params["identityCard"], defaults = {'identity_card': params["identityCard"],
                                                                                                         'add_time': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
        print(p, created)
        registrationsheet = RegistrationSheet.get(RegistrationSheet.identity_card == params["identityCard"])
        registrationsheet.name = params["name"]
        registrationsheet.sex = params["sex"]
        registrationsheet.birthday = params["birthday"]
        registrationsheet.position = params["position"]
        registrationsheet.local = params["local"]
        registrationsheet.marital_status = params["maritalStatus"]
        registrationsheet.identity_card = params["identityCard"]
        registrationsheet.tel = params["tel"]
        registrationsheet.registered_permanent_residence = params["registeredPermanentResidence"]
        registrationsheet.residential_address = params["residentialAddress"]
        registrationsheet.urgent_name = params["urgentName"]
        registrationsheet.urgent_tel = params["urgentTel"]
        registrationsheet.salary_expectation = params["salaryExpectation"]
        registrationsheet.fastest_work_time = params["fastestWorkTime"]
        registrationsheet.learn_start_time = params["learnStartTime"]
        registrationsheet.learn_end_time = params["learnEndTime"]
        registrationsheet.school_name = params["schoolName"]
        registrationsheet.examination_type = params["examinationType"]
        registrationsheet.major = params["major"]
        registrationsheet.graduate_type = params["graduateType"]
        registrationsheet.educationlist = params["educationList"]
        registrationsheet.nation = params["nation"]
        registrationsheet.name = params["name"]
        registrationsheet.stature = params["stature"]
        registrationsheet.weight = params["weight"]
        registrationsheet.e_mail = params["eMail"]
        registrationsheet.health = params["health"]
        registrationsheet.certificate_level = params["certificateLevel"]
        registrationsheet.english_level = params["englishLevel"]
        registrationsheet.self_comment = params["selfComment"]
        registrationsheet.specialty = params["specialty"]
        registrationsheet.workexperience = params["workexperience"]
        registrationsheet.family = params["family"]
        registrationsheet.imgbase64 = params["dataUrl"]
        registrationsheet.perfect_flag = '已完善'
        registrationsheet.update_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
#         registrationsheet.open_bank = params["openBank"]
#         registrationsheet.account_number = params["accountNumber"]

        registrationsheet.save()
        return super().resultSet(200, "修改成功", [])
        raise Exception("修改失败")


if __name__ == '__main__': 
    view = ApplicantDetailsView()
    data = view.updateRegistration()
